import request from '@/utils/request'

// 获取疫苗分类列表
export function getVaccineCategories() {
  return request({
    url: '/api/vaccineCategory/search',
    method: 'get'
  })
}

// 获取疫苗列表
export function getVaccineList(params) {
  return request({
    url: '/app/vaccine/page',
    method: 'post',
    data: params
  })
}

// 根据分类ID获取疫苗列表
export function getVaccinesByCategoryId(categoryId) {
  if (categoryId !== null && categoryId !== undefined && categoryId !== 0) {
    return request({
      url: `/api/vaccineCategory/vaccines?categoryId=${categoryId}`,
      method: 'get'
    })
  } else {
    return request({
      url: '/api/vaccineCategory/vaccines',
      method: 'get'
    })
  }
}

// 提交疫苗预约
export function createVaccinationAppointment(data) {
  return request({
    url: '/api/vaccinationAppointment/create',
    method: 'post',
    data
  })
}

// 获取可预约医院列表
export function getHospitalList() {
  return request({
    url: '/api/app/hospital/list',
    method: 'get'
  })
}

// 获取可预约时间段
export function getAvailableTimeSlots(params) {
  return request({
    url: '/api/vaccination/appointment/available-time',
    method: 'get',
    params
  })
} 